<?php
/**
 * User: jwj
 * Date: 2017/3/14
 * Time: 10:15
 * 短信接口
 */
class smsControl extends Control{

    public function __construct(){
        parent::__construct();
    }

    /**
     * 发送短信
     */
    public function sendOp(){
        $_SESSION['text_mobile'] = '13812345678';
        $str = random(5);
        $_SESSION['text_code'] = $str;
        $data['PHPSESSID'] = session_id();
        $data['random'] = $str;
        $this->response($data,4004,json_encode($data));

        ini_set("display_errors", "On");
        require_once(BASE_DATA_PATH.'/vendors/sms/SMS.php');
        $mobile = $_POST['mobile'];
        if(empty($mobile)){
            $this->response('',5003,'mobile不能为空');
        }
        $isMobile = $this->is_mobile($mobile);
        if(!$isMobile){
            $this->response('',5003,'手机号格式不正确');
        }
        $sms = new SMS();
        $result = $sms->send($mobile);
        $this->response($result,2000,'获取成功');
    }

    /**
     * 密码校验
     */
    public function checkCodeOp(){
        ini_set("display_errors", "On");
        require_once(BASE_DATA_PATH.'/vendors/sms/SMS.php');
        $mobile = $_POST['mobile'];
        $mobile_code = $_POST['mobile_code'];
        $sms = new SMS();
        $result = $sms->checkCode($mobile,$mobile_code);
        $this->response($result,2000,'获取成功');
    }








}